09. Helpful Tools
Helpful Tools
With so many degrees of freedom, debugging and troubleshooting can be a painful process.
In order to make things a little bit simpler, listed here are some tools that might make your life a little bit easier.
Constraining Forces and Torques
It is possible to constrain forces and torques on the quad rotor's body frame. This can be useful if you're trying to debug only a single degree of freedom.
Example: Disallow movement along the quad's X axis
$ rosservice call /quad_rotor/x_force_constrained "data: true"
Example: Disallow rotation about the quad's X axis
$ rosservice call /quad_rotor/x_torque_constrained "data: true"
Setting the Camera Pose
To set the camera pose you can either right click in the simulator and drag, or you can use the following service call, where the data parameter may take on the following values:
- 0: Orthogonal to the inertial frame's YZ plane, facing the positive X direction.
- 1: Orthogonal to the inertial frame's XZ plane, facing the positive Y direction.
- 2: Orthogonal to the intertial frame's XY plane, facing the negative Z direction.
- 3: Perspective view, facing the quad's body frame origin from the -X,-Y, +Z quadrant.
$ rosservice call /quad_rotor/camera_pose_type "data: 0"
To reset the camera pose, to the default pose, you can use the service call, or right click.
Setting the Camera Distance
To set the distance between the camera and the quad's body frame, you can use the /quad_rotor/camera_distance service.
For example, to set the camera distance to be 20 meters, you would call the service as follows:
$ rosservice call /quad_rotor/camera_distance "data: 20.0"
To reset the camera distance to the default, simply right click in the simulator.
Disabling Gravity
Gravity can be a harsh reality. Particularly when you're dealing with attitude tuning. Fortunately, we can disable gravity in the simulator for the purposes of debugging.
To so, call the /quad_rotor/gravity service as follows:
$ rosservice call /quad_rotor/gravity "data: false"
Setting Pose
To set the quad pose, use the /quad_rotor/set_pose service. The following service call will place the quad at the origin:
$ rosservice call /quad_rotor/set_pose "pose:
position:
x: 0.0
y: 0.0
z: 0.0
orientation:
x: 0.0
y: 0.0
z: 0.0
w: 0.0"
rqt_plot
ROS provides a simple 2D graph plotting tool in the form of rqt_plot
. rqt_plot
allows you to easily plot scalar values contained within messages on a topic in real time.
To demonstrate its usage, launch your quadrotor simulator and the positional controller first.
Then open an instance of rqt_plot
from a new terminal:
$ rqt_plot
You can now visualize quad’s motion in the z-direction by adding the following in the Topic section and hitting the + icon:
/quad_rotor/pose/pose/position/z
At any point of time you can add more topics to the same plot by repeating the previous step.
Note: Keep an eye on your CPU usage while running rqt_plot, it may (or may not) slow down your system a bit.
By default, the x-axis range is fairly small and scrolls across the screen rapidly. To better visualize quad’s overall movement, click the green check mark and adjust the x and y axes range via the Figure Options.
Now if you use dynamic_reconfigure
to make a step input in the position controller by changing set_point_z from 0 to 10, you should be able to visualize the response:
Feel free to play around with various settings, add axis labels, title, etc.
You can pause the plot at any moment using the pause button in top-right corner and resume using the same, or you can toggle autoscroll on/off.
rqt_plot also allows you to save the plot at any moment by hitting the Save icon.
To remove a topic from the graph simply hit the - icon right besides the + icon and select the topic that you would like to remove.
Again feel free to play around with various options and try to visualize/track the quad’s motion along all three axes.
More details about rqt_plot can be found here.